package com.example.concurrentprogramming8016.thread;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
 * @author liyanhao
 * @Date 2023-01-03 16:49
 */
public class LockSupportTest {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new ParkThread());
        thread.start();
        TimeUnit.SECONDS.sleep(2);
        System.out.println("唤醒 parkThread");
        LockSupport.unpark(thread);
    }

    static class ParkThread implements Runnable {

        @Override
        public void run() {
            System.out.println("ParkThread run 开始执行");
            LockSupport.park();
            System.out.println("ParkThread run 执行完毕");
        }
    }
}
